package com.mmche.web.service.impl;


import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.framework.support.domain.PageMan;
import com.mmche.car.dao.CarDao;
import com.mmche.car.pojo.Car;
import com.mmche.car.service.CarService;
import com.mmche.car.service.impl.CarServiceImpl;

@Service("webCarService")
public class WebCarService extends CarServiceImpl implements CarService{
	
	@Resource(name="webCarDao")
	private CarDao carDao;
	
	@SuppressWarnings("rawtypes")
	@Override
	public int getCarCountByMap(Map map) {
		return this.carDao.getCountByMap(map);
	}

	@SuppressWarnings("rawtypes")
	@Override
	public List<Car> getCarPageByMap(Map map, int start, int limit) {
		return this.carDao.getPageByMap(map, start, limit);
	}
	
	@SuppressWarnings("rawtypes")
	@Override
	public int searchCarCountByMap(Map map) {
		return this.carDao.searchCountByMap(map);
	}

	@SuppressWarnings("rawtypes")
	@Override
	public List<Car> searchCarPageByMap(Map map, int start, int limit) {
		return this.carDao.searchPageByMap(map, start, limit);
	}
	@SuppressWarnings({ "rawtypes", "unchecked" })
	@Override
	public List<Car> getHotCars(int limit) {
		Map map = new HashMap<String,String>();
		map.put("status", Car.STATUS_SHELVES);
		map.put("sort", "ctr");
		return this.carDao.getPageByMap(map, 0, limit);
	}

	@Override
	public List<Car> getSameBrandCars(Car car) {
		return this.carDao.getSameBrandCars(car);
	}

	@Override
	public List<Car> getSamePriceCars(Car car) {
		return this.carDao.getSamePriceCars(car);
	}
	
	@Override
	public Car getCarById(String id){
		return this.carDao.findById(id);
	}
	
	@Override
	public List<Car> getCarPageByMap(Map<String, Object> map, PageMan pm) {
		return this.carDao.getPageByMap(map, pm);
	}
	
	@Override
	public Car updateCar(Car car) {
		return this.carDao.update(car);
	}
}
